package com.example.shop_2304.adapter

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.CategoryEntityItem
import com.example.shop_2304.R

class TwoCateAdapter:BaseQuickAdapter<CategoryEntityItem,BaseViewHolder>(R.layout.item_twocate) {
    override fun convert(holder: BaseViewHolder, item: CategoryEntityItem) {
        holder.setText(R.id.two_tv,"------${item.name}------")
        //rv 如何赋值和 fragment 或者activity中一样
        //找到rv控件
        val recyclerView1 = holder.getView<RecyclerView>(R.id.two_rv)
        //需要有一个适配器（item布局）
        val twoCateChildAdapter = TwoCateChildAdapter()
        twoCateChildAdapter.data.addAll(item.child)
        recyclerView1.adapter = twoCateChildAdapter
        //显示布局样式
        recyclerView1.layoutManager = GridLayoutManager(context,3)
    }
}